package com.wd.rim.fragment

import activity.TiwenActivity
import android.content.Intent
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.LinearLayoutManager
import apdate.QuestionApdate
import com.wd.common.base.BaseFragment
import com.wd.common.viewmodel.MyViewModel
import com.wd.rim.databinding.FragmentQuestionsBinding

class QuestionsFragment : BaseFragment<FragmentQuestionsBinding>() {
    private val mViewModel:MyViewModel by viewModels()
    private var apdate:QuestionApdate?=null
    override fun getViewBinding(
        inflater: LayoutInflater,
        container: ViewGroup?
    ):FragmentQuestionsBinding=FragmentQuestionsBinding.inflate(layoutInflater)

    override fun initData() {
        mViewModel.getQuestion("1","10")
        mViewModel.question.observe(this){
            apdate=context?.let { it1->QuestionApdate(it1,it) }
            binding.recyId.layoutManager=LinearLayoutManager(context)
            binding.recyId.adapter=apdate
//            apdate=context?.let {it1-> SquareApdate(it1,it) }
        }
        binding.Tiwen.setOnClickListener {
            val intent = Intent()
            context?.let { intent.setClass(it,TiwenActivity::class.java) }
            startActivity(intent)
        }



    }

}